package net.cyan.commons.log;

/**
 * 
 * @author camel
 * @date 2008-12-10
 */
public class LogPrintable implements Printable, PrintableProvider
{
    private Log log;

    private LogLevel level;

    public LogPrintable(Log log, LogLevel level)
    {
        this.log = log;
        this.level = level;
    }

    public void println(String s)
    {
        if (level == LogLevel.debug)
            log.debug(s);
        else if (level == LogLevel.info)
            log.info(s);
        else if (level == LogLevel.warn)
            log.warn(s);
        else if (level == LogLevel.error)
            log.error(s);
        else
            log.fatal(s);
    }

    public Printable getPrintable()
    {
        return this;
    }

    public void flush()
    {
    }
}
